﻿@(
 Ajax.Dna().Widget()
 .UserPreferences(@<text>
<div>@Html.Global("tmpl", "ContactCard_ViewMode")</div>
<div>@(Ajax.Dna().ComboBox(item.GenerateFieldID("ViewMode")).Bind(new string[] { "Full", "Medium", "Mini" }).Select(item.GetString("ViewMode")).GetHtml())</div>
<div>@Html.Global("RES_COMPANY")</div>
<div>@Ajax.Dna().TextBox(item.GenerateFieldID("Company")).Value(item.GetString("Company")).GetHtml()</div>
<div>@Html.Global("RES_DESC")</div>
<div>@Ajax.Dna().TextArea(item.GenerateFieldID("Description")).Value(item.GetString("Description")).Resizable().GetHtml()</div>
<div>
    @Html.Global("RES_IMAGEURL")</div>
<div style="margin-top: 5px;">
    <table>
        <tr>
            <td>
                @(Ajax.Dna().TextBox(item.GenerateFieldID("LogoUrl"))
                                .Value(item.UserPreferences["LogoUrl"] != null ? item.GetString("LogoUrl") : "")
                .GetHtml()
            )
            </td>
            <td>
                @Ajax.Dna().Button(item.GenerateFieldID("btnBrowseIcon")).LocText("RES_BROWSE").Click("$dna.fileDlg(\"" + Url.Action("Dialog", "WebFiles", new { Area = "", website = WebSiteContext.Current.Web.Name }) + "\",$(\"#" + item.GenerateFieldID("LogoUrl") + "\"));").ImageIcons(Url.Content("~/content/images/icon_folder_open_16.gif")).GetHtml()
            </td>
        </tr>
    </table>
</div>
<div>@Html.Global("RES_CONTACT_TITLE")</div>
<div>@Ajax.Dna().TextBox(item.GenerateFieldID("ContactTitle")).Value(item.GetString("ContactTitle")).GetHtml()</div>
<div>@Html.Global("RES_CONTACT")</div>
<div>@Ajax.Dna().TextBox(item.GenerateFieldID("Contact")).Value(item.GetString("Contact")).GetHtml()</div>
<div>@Html.Global("RES_EMAIL")</div>
<div>@Ajax.Dna().TextBox(item.GenerateFieldID("Email")).Value(item.GetString("Email")).GetHtml()</div>
<div>@Html.Global("RES_PHONE")</div>
<div>@Ajax.Dna().TextBox(item.GenerateFieldID("Phone")).Value(item.GetString("Phone")).GetHtml()</div>
<div>@Html.Global("RES_MOBILE")</div>
<div>@Ajax.Dna().TextBox(item.GenerateFieldID("Mobile")).Value(item.GetString("Mobile")).GetHtml()</div>
<div>@Html.Global("RES_FAX")</div>
<div>@Ajax.Dna().TextBox(item.GenerateFieldID("Fax")).Value(item.GetString("Fax")).GetHtml()</div>
<div>@Html.Global("RES_WEBSITE")</div>
<div>@Ajax.Dna().TextBox(item.GenerateFieldID("HomePage")).Value(item.GetString("HomePage")).GetHtml()</div>
<div>@Html.Global("RES_COUNTRY")</div>
<div>@Ajax.Dna().TextBox(item.GenerateFieldID("Country")).Value(item.GetString("Country")).GetHtml()</div>
<div>@Html.Global("RES_State")</div>
<div>@Ajax.Dna().TextBox(item.GenerateFieldID("State")).Value(item.GetString("State")).GetHtml()</div>
<div>@Html.Global("RES_CITY")</div>
<div>@Ajax.Dna().TextBox(item.GenerateFieldID("City")).Value(item.GetString("City")).GetHtml()</div>
<div>@Html.Global("RES_POSTCODE")</div>
<div>@Ajax.Dna().TextBox(item.GenerateFieldID("ZipCode")).Value(item.GetString("ZipCode")).GetHtml()</div>
<div>@Html.Global("RES_ADDRESS")</div>
<div>@Ajax.Dna().TextBox(item.GenerateFieldID("Address")).Value(item.GetString("Address")).GetHtml()</div>
</text>)

 .Content(@<text>
@{
    var company = new
    {
        Name = GE.GetContent(item.GetString("Company")),
        Description = GE.GetContent(item.GetString("Description")),
        Contact = GE.GetContent(item.GetString("Contact")),
        ContactTitle = GE.GetContent(item.GetString("ContactTitle")),
        Phone = item.GetString("Phone"),
        Mobile = item.GetString("Mobile"),
        Fax = item.GetString("Fax"),
        Email = item.GetString("Email"),
        Country = GE.GetContent(item.GetString("Country")),
        State = GE.GetContent(item.GetString("State")),
        City = GE.GetContent(item.GetString("City")),
        Address = GE.GetContent(item.GetString("Address")),
        LogoUrl = string.IsNullOrEmpty(item.GetString("LogoUrl")) ? "" : Url.Content(item.GetString("LogoUrl")),
        HomePage = item.GetString("HomePage"),
        ZipCode = item.GetString("ZipCode")
    };
}
<style type="text/css">
    .d-info { position: relative; }
    .d-info > section { display: none; position: absolute; top: 0px; left: 0px; background: #fff; opacity: 0.8; filter: Alpha(Opacity=80); color: #000; }
    .d-info > section > header { color: #000; margin-bottom: 10px;}
    .d-info > section > header>p{color: #6d6d6d; margin-top: 0px;}
    .d-info:hover > section { display: block; opacity:1; filter: Alpha(Opacity=100);height:90%;}
</style>
<div class="d-info">
    @if (item.GetString("ViewMode").Equals("Mini"))
    {
        <section>
            <header>@company.Name
            </header>
            <p>@company.Description</p>
            <footer>
                <ul class="d-horizontal-list">
                    <li>@Html.Global("RES_PHONE") @company.Phone</li><li>@Html.Global("RES_ADDRESS"):@company.Address
                        @company.ZipCode @company.City @company.State @company.Country </li>
                </ul>
            </footer>
        </section>
    }
    <table style="width: 100%">
        <tr>
            @if (!string.IsNullOrEmpty(company.LogoUrl))
            {
                <td style="min-width: 64px; text-align: center; vertical-align: top; padding: 10px;">
                    @if (!string.IsNullOrEmpty(company.HomePage))
                    { 
                        <a href="@company.HomePage">
                            <img src="@Url.Content(company.LogoUrl)" alt="logo" />
                        </a>
                    }
                    else
                    {   <img src="@Url.Content(company.LogoUrl)" alt="logo" />}
                </td>
            }
            @if (!item.GetString("ViewMode").Equals("Mini"))
            {
                <td style="vertical-align: top;">
                    <section>
                        @if (!string.IsNullOrEmpty(company.Name))
                        {
                            <header style="margin-bottom: 10px;">@company.Name
                            </header>
                        }
                        <p style="color: #6d6c6c; margin-top: 0px;">@company.Description</p>
                        @if (item.GetString("ViewMode").Equals("Detail"))
                        {
                            <table style="margin-top: 10px;">
                                <tr>
                                    <td style="white-space: nowrap; width: 20px; vertical-align: top;">
                                        <b>@Html.Global("RES_CONTACT_TITLE")</b> :
                                    </td>
                                    <td style="vertical-align: top;">
                                        @company.ContactTitle
                                    </td>
                                    <td>
                                        <b>@Html.Global("RES_CONTACT")</b>:
                                    </td>
                                    <td>@company.Contact
                                    </td>
                                </tr>
                                <tr>
                                    <td style="white-space: nowrap; vertical-align: top;">
                                        <b>@Html.Global("RES_PHONE")</b>:
                                    </td>
                                    <td>
                                        @company.Phone
                                    </td>
                                    <td style="white-space: nowrap;">
                                        <b>@Html.Global("RES_MOBILE")</b>:
                                    </td>
                                    <td style="vertical-align: top;">
                                        @company.Mobile
                                    </td>
                                </tr>
                                <tr>
                                    <td style="white-space: nowrap; vertical-align: top;">
                                        <b>@Html.Global("RES_FAX")</b>:
                                    </td>
                                    <td>
                                        @company.Fax
                                    </td>
                                </tr>
                                <tr>
                                    <td style="white-space: nowrap;">
                                        <b>@Html.Global("RES_EMAIL")</b>:
                                    </td>
                                    <td style="white-space: nowrap;" colspan="2">
                                        <a href="mailto:@company.Email" title="@company.Email">
                                            @company.Email</a>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="white-space: nowrap; vertical-align: top;">
                                        <b>@Html.Global("RES_WEBSITE")</b>:
                                    </td>
                                    <td style="vertical-align: top;" colspan="2">
                                        <a href='@company.HomePage' target="_blank">
                                            @company.HomePage</a>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="white-space: nowrap; vertical-align: top;">
                                        <b>@Html.Global("RES_ADDRESS")</b>:
                                    </td>
                                    <td style="vertical-align: top;">
                                        <div>
                                            @company.Address @company.ZipCode
                                        </div>
                                        <div>@company.City @company.State @company.Country
                                        </div>
                                    </td>
                                </tr>
                            </table>
                        }
                    </section>
                </td>
            }
        </tr>
        @if (item.GetString("ViewMode").Equals("Medium"))
        {
            <tr>
                <td colspan="2">
                    <ul class="d-horizontal-list">
                        <li>@Html.Global("RES_PHONE") @company.Phone</li><li>@Html.Global("RES_ADDRESS"):@company.Address
                            @company.ZipCode @company.City @company.State @company.Country </li>
                    </ul>
                </td>
            </tr>
        }
    </table>
</div>
</text>
        )
     .Preview(@<text>
<table style="width: 100%">
    <tr>
        <td style="white-space: nowrap; vertical-align: top;">
            @Html.Global("RES_COMPANY"):
        </td>
        <td style="vertical-align: top;" colspan="2">
            Sample company inc.
        </td>
    </tr>
    <tr>
        <td style="white-space: nowrap; width: 20px; vertical-align: top;">
            @Html.Global("RES_CONTACT") :
        </td>
        <td style="vertical-align: top;">
            Json Tom
        </td>
    </tr>
    <tr>
        <td style="white-space: nowrap; vertical-align: top;">
            @Html.Global("RES_PHONE"):
        </td>
        <td style="vertical-align: top;">
            +01 888 888
        </td>
    </tr>
    <tr>
        <td style="white-space: nowrap; vertical-align: top;">
            @Html.Global("RES_MOBILE"):
        </td>
        <td style="vertical-align: top;">
            +01 888 888
        </td>
    </tr>
    <tr>
        <td style="white-space: nowrap; vertical-align: top;">
            @Html.Global("RES_FAX"):
        </td>
        <td style="vertical-align: top;">
            +01 888 888
        </td>
    </tr>
    <tr>
        <td style="white-space: nowrap; vertical-align: top;">
            @Html.Global("RES_EMAIL"):
        </td>
        <td style="vertical-align: top;">
            <a href="mailto:sample@dotnetage.com" title="sample@dotnetage.com">sample@dotnetage.com</a>
        </td>
    </tr>
    <tr>
        <td style="white-space: nowrap; vertical-align: top;">
            @Html.Global("RES_WEBSITE"):
        </td>
        <td style="vertical-align: top;">
            <a href="http://www.dotnetage.com" target="_blank">http://www.dotnetage.com</a>
        </td>
    </tr>
    <tr>
        <td style="white-space: nowrap; vertical-align: top;">
            @Html.Global("RES_ADDRESS"):
        </td>
        <td style="vertical-align: top;">
            XXX Amphitheate Parkway USA
        </td>
    </tr>
    <tr>
        <td style="white-space: nowrap; vertical-align: top;">
            @Html.Global("RES_POSTCODE"):
        </td>
        <td style="vertical-align: top;">
            CA
        </td>
    </tr>
</table>
</text>)
     .GetHtml()
)
